package com.app.android.coliy.manager;

import com.app.android.coliy.MyApplication;
import com.app.android.coliy.constant.SPConstants;
import com.app.android.coliy.tool.SPUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class LangugeManager {


    public static List<Locale> getAllLanguge() {
        List<Locale> list = new ArrayList<>();
//        list.add(Locale.getDefault());
        list.add(Locale.ENGLISH);      //英文
        list.add(Locale.CHINESE);       //中文
        list.add(Locale.FRENCH);        //法语
        list.add(Locale.JAPANESE);       //日语
        list.add(Locale.KOREAN);        //韩语
        list.add(Locale.GERMAN);        //德语
        list.add(Locale.ITALIAN);        //意大利语
        list.add(new Locale("es", "ES"));        //西班牙语
        return list;
    }

    //获取语言
    public static Locale getCurrentLanguge() {
        String languge = SPUtil.getStringValue(MyApplication.context, SPConstants.Languge, Locale.getDefault().getLanguage());
        Locale locale = new Locale(languge);
        return locale;
    }

    //保存当前使用的语言
    public static void saveLanguge(Locale locale) {
        SPUtil.putValue(MyApplication.context, SPConstants.Languge, locale.getLanguage());
    }

}
